
var httpObject;

function GetHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	else
	{
		alert('Your browser is not supported');
	}
	return null;
}

function ReadFile(fileName)
{
	httpObject = GetHttpObject();
    if (httpObject != null) 
	{
        httpObject.open("GET", "FileRead.php?file=" + fileName, false);
        httpObject.send(null);
		return httpObject.responseText;
    }
}

function OverwriteFile(fileName, data_array)
{
	httpObject = GetHttpObject();
    if (httpObject != null) 
	{
		var strData = "FileWrite.php?file=" + fileName;
		var count = 0;
		
		strData += "&count=" + data_array.length;
		
		for (count in data_array)
		{
			strData += "&data" + count + "=" + data_array[count];
		}
		
        httpObject.open("GET", strData, false);
        httpObject.send(null);
    }
}
